package com.lanlian.cayman.adapter;

import android.graphics.Color;
import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.lanlian.cayman.R;
import com.lanlian.commonlib.bean.RechargeInfo;

import java.util.List;

/**
 * <pre>
 *     author : huxiaobo
 *     e-mail : huxiaobo@xlanlian.com
 *     date   : 2018/8/15 16:55
 *     desc   : 充值Adapter
 *     version: 1.0
 * </pre>
 */
public class RechargeAdapter extends BaseQuickAdapter<RechargeInfo, BaseViewHolder> {

    public RechargeAdapter(int layoutResId, @Nullable List<RechargeInfo> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, RechargeInfo item) {
        helper.setBackgroundColor(R.id.lay_position, (helper.getLayoutPosition() + 1) % 2 == 0 ?
                mContext.getResources().getColor(R.color.color_bg_text_view_style2) :
                mContext.getResources().getColor(R.color.color_bg_text_view_style3));
        helper.addOnClickListener(R.id.tv_recharge);
        if (item.getStatus() == 1) {
            helper.setBackgroundRes(R.id.tv_recharge, R.drawable.bg_2_b0bccb);
            helper.setTextColor(R.id.tv_recharge, mContext.getResources().getColor(R.color.color_text_style23));
            helper.setText(R.id.tv_recharge, "充值成功");
        } else {
            helper.setBackgroundRes(R.id.tv_recharge, R.drawable.bg_2_4385f3);
            helper.setTextColor(R.id.tv_recharge, Color.parseColor("#FFFFFF"));
            helper.setText(R.id.tv_recharge, "充值");
        }
        helper.setText(R.id.tv_currency_type, item.getCurrency())
                .setText(R.id.tv_money, String.valueOf(item.getPrice()));
    }

}
